import { getShopList, getData } from '../api/index'

export let get_Shop_List = () => {
    return async (dispatch) => {
        let { data } = await getShopList()
        dispatch({
            type: 'GET_SHOP_LIST',
            payload: data
        })
    }
}

//获取下标
export let setIndex = (index) => {
    return dispatch => {
        dispatch({
            type: 'SET_INDEX',
            payload: index
        })
    }
}

//加入购物车
export let addShop = (item) => {
    return dispatch => {
        dispatch({
            type: 'ADD_SHOP',
            payload: item
        })
    }
}

//------
export let Subtract = (index) => {
    return dispatch => {
        dispatch({
            type: 'SUBTRACT',
            payload: index
        })
    }
}

//++++++
export let Add = (index) => {
    return dispatch => {
        dispatch({
            type: 'ADD',
            payload: index
        })
    }
}

export let checkItem = (index) => {
    return dispatch => {
        dispatch({
            type: 'CHECK_ITEM',
            payload: index
        })
    }
}

export let allCheckItem = () => {
    return dispatch => {
        dispatch({
            type: 'ALL_CHECK_ITEM'
        })
    }
}

export let detail_Btn = (item) => {
    return dispatch => {
        dispatch({
            type: 'DETAIL_BTN',
            payload: item
        })
    }
}

export let get_Data = () => {
    return async (dispatch) => {
        let { data } = await getData()
        dispatch({
            type: 'GET_DATA',
            payload: data
        })
    }
}